package org.example.aicloud.task;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.xxl.job.core.handler.annotation.XxlJob;
import jakarta.annotation.Resource;
import org.example.aicloud.entity.User;
import org.example.aicloud.service.IUserService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class TimedTask {

    @Value("${system.user.use-count}")
    private Integer userCount;

    @Resource
    private IUserService userService;
    @XxlJob("setUserUseCount")
    public void setUserUseCount() {
        UpdateWrapper<User>  wrapper = new UpdateWrapper<>();
        wrapper.set("usercount", userCount);
        if (!userService.update(wrapper)) {
            //todo 调用通知中心通知相关人员解决和排查问题
        }
    }

}
